package com.crm.custinfo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.crm.custinfo.domain.HitPackage;
import com.crm.custinfo.service.IHitPackageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 全量撞库包Controller
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/crmsys/hitPackage")
public class HitPackageController extends BaseController
{
    @Autowired
    private IHitPackageService hitPackageService;

    /**
     * 查询全量撞库包列表
     */
    @PreAuthorize("@ss.hasPermi('crmsys:hitPackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(HitPackage hitPackage)
    {
        startPage();
        List<HitPackage> list = hitPackageService.selectHitPackageList(hitPackage);
        return getDataTable(list);
    }

    /**
     * 导出全量撞库包列表
     */
    @PreAuthorize("@ss.hasPermi('crmsys:hitPackage:export')")
    @Log(title = "全量撞库包", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HitPackage hitPackage)
    {
        List<HitPackage> list = hitPackageService.selectHitPackageList(hitPackage);
        ExcelUtil<HitPackage> util = new ExcelUtil<HitPackage>(HitPackage.class);
        util.exportExcel(response, list, "全量撞库包数据");
    }

    /**
     * 获取全量撞库包详细信息
     */
    @PreAuthorize("@ss.hasPermi('crmsys:hitPackage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hitPackageService.selectHitPackageById(id));
    }

    /**
     * 新增全量撞库包
     */
    @PreAuthorize("@ss.hasPermi('crmsys:hitPackage:add')")
    @Log(title = "全量撞库包", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HitPackage hitPackage)
    {
        return toAjax(hitPackageService.insertHitPackage(hitPackage));
    }

    /**
     * 修改全量撞库包
     */
    @PreAuthorize("@ss.hasPermi('crmsys:hitPackage:edit')")
    @Log(title = "全量撞库包", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HitPackage hitPackage)
    {
        return toAjax(hitPackageService.updateHitPackage(hitPackage));
    }

    /**
     * 删除全量撞库包
     */
    @PreAuthorize("@ss.hasPermi('crmsys:hitPackage:remove')")
    @Log(title = "全量撞库包", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hitPackageService.deleteHitPackageByIds(ids));
    }
}
